package com.anda.logistics.dao.impl;

import java.io.Serializable;
import java.text.ParseException;
import java.util.List;

import org.hibernate.HibernateException;
import org.springframework.stereotype.Component;

import com.anda.logistics.dao.AndaBaseDao;
import com.anda.logistics.util.JQGridJsonData;
import com.anda.logistics.util.JQGridPager;
@Component
public class AndaBaseDaoImpl extends AndaBaseSuperDao implements AndaBaseDao{

	@Override
	public Serializable save(Object entity){
		 return sessionFactory.getCurrentSession().save(entity);
	}
	
	@Override
	public void update(Object entity){
		sessionFactory.getCurrentSession().update(entity);	
	}
	
	@Override
	public void delete(Object entity){
		sessionFactory.getCurrentSession().delete(entity);
	}
	
	@Override
	public Object get(Class<Object> c, Serializable id){
		return sessionFactory.getCurrentSession().get(c, id);
	}
	@Override
	public List<Object> getBasePagerList(JQGridPager pager, String tableName) {
		return pager.getPagerList(sessionFactory.getCurrentSession(), tableName);
	}
	@Override
	public long getBasePagerRecords(JQGridPager pager, String tableName) {
		return pager.getPagerRecords(sessionFactory.getCurrentSession(), tableName);
	}
//	@Override
//	public JQGridJsonData getJQGridJsonData(JQGridPager pager, String tableName, String idName, String [] columns) {
//		return pager.getJQGridJsonData(sessionFactory.getCurrentSession(), tableName, idName, columns);
//	}
	@Override
	public JQGridJsonData getJQGridJsonData(JQGridPager pager, String idName, String [] columns, Class clazz) throws NoSuchFieldException, SecurityException, HibernateException, ParseException {
		return pager.getJQGridJsonData(sessionFactory.getCurrentSession(), idName, columns, clazz);
	}
}
